USE [master]
GO
/****** Object:  Database [TahorCRM]    Script Date: 08/03/2012 16:31:53 ******/
CREATE DATABASE [TahorCRM] ON  PRIMARY 
( NAME = N'CRMTest', FILENAME = N'E:\SQL2005\DATA\TMP\CRMTest.mdf' , SIZE = 3072KB , MAXSIZE = 10240000KB , FILEGROWTH = 102400KB )
 LOG ON 
( NAME = N'CRMTest_log', FILENAME = N'E:\SQL2005\LOGS\TMP\CRMTest_log.ldf' , SIZE = 1024KB , MAXSIZE = 5120000KB , FILEGROWTH = 51200KB )
GO
ALTER DATABASE [TahorCRM] SET COMPATIBILITY_LEVEL = 90
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [TahorCRM].[dbo].[sp_fulltext_database] @action = 'disable'
end
GO
ALTER DATABASE [TahorCRM] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [TahorCRM] SET ANSI_NULLS OFF
GO
ALTER DATABASE [TahorCRM] SET ANSI_PADDING OFF
GO
ALTER DATABASE [TahorCRM] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [TahorCRM] SET ARITHABORT OFF
GO
ALTER DATABASE [TahorCRM] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [TahorCRM] SET AUTO_CREATE_STATISTICS ON
GO
ALTER DATABASE [TahorCRM] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [TahorCRM] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [TahorCRM] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [TahorCRM] SET CURSOR_DEFAULT  GLOBAL
GO
ALTER DATABASE [TahorCRM] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [TahorCRM] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [TahorCRM] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [TahorCRM] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [TahorCRM] SET  DISABLE_BROKER
GO
ALTER DATABASE [TahorCRM] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [TahorCRM] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [TahorCRM] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [TahorCRM] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [TahorCRM] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [TahorCRM] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [TahorCRM] SET  READ_WRITE
GO
ALTER DATABASE [TahorCRM] SET RECOVERY SIMPLE
GO
ALTER DATABASE [TahorCRM] SET  MULTI_USER
GO
ALTER DATABASE [TahorCRM] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [TahorCRM] SET DB_CHAINING OFF
GO
USE [TahorCRM]
GO
/****** Object:  Table [dbo].[AddressTypes]    Script Date: 08/03/2012 16:31:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[AddressTypes](
	[AddressTypeId] [int] NOT NULL,
	[Name] [varchar](max) NOT NULL,
	[CreatedAt] [datetime] NOT NULL,
	[UpdatedAt] [datetime] NOT NULL,
 CONSTRAINT [PK_AddressTypes] PRIMARY KEY CLUSTERED 
(
	[AddressTypeId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[ContactDetailTypes]    Script Date: 08/03/2012 16:31:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[ContactDetailTypes](
	[ContactDetailTypeId] [int] NOT NULL,
	[Name] [varchar](max) NOT NULL,
	[CreatedAt] [datetime] NOT NULL,
	[UpdatedAt] [datetime] NOT NULL,
 CONSTRAINT [PK_ContactDetailTypes] PRIMARY KEY CLUSTERED 
(
	[ContactDetailTypeId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[CommentTypes]    Script Date: 08/03/2012 16:31:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[CommentTypes](
	[CommentTypeId] [int] NOT NULL,
	[Name] [varchar](max) NOT NULL,
	[CreatedAt] [datetime] NOT NULL,
	[UpdatedAt] [datetime] NOT NULL,
 CONSTRAINT [PK_CommentTypes] PRIMARY KEY CLUSTERED 
(
	[CommentTypeId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[InformationStreams]    Script Date: 08/03/2012 16:31:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[InformationStreams](
	[InformationStreamId] [int] NOT NULL,
	[Name] [varchar](50) NOT NULL,
	[ShortDescription] [varchar](150) NOT NULL,
	[Description] [varchar](max) NULL,
	[CreatedAt] [datetime] NOT NULL,
	[UpdatedAt] [datetime] NOT NULL,
	[DeletedAt] [datetime] NULL,
 CONSTRAINT [PK_InformationStreams] PRIMARY KEY CLUSTERED 
(
	[InformationStreamId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[AvatarTypes]    Script Date: 08/03/2012 16:31:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[AvatarTypes](
	[AvatarTypeId] [int] NOT NULL,
	[Name] [varchar](50) NOT NULL,
	[ShortDescription] [varchar](150) NULL,
	[CreatedAt] [datetime] NOT NULL,
	[UpdatedAt] [datetime] NOT NULL,
	[DeletedAt] [datetime] NULL,
 CONSTRAINT [PK_AvatarTypes] PRIMARY KEY CLUSTERED 
(
	[AvatarTypeId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Groups]    Script Date: 08/03/2012 16:31:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Groups](
	[GroupId] [int] NOT NULL,
	[Name] [varchar](max) NULL,
	[CreatedAt] [datetime] NOT NULL,
	[UpdatedAt] [datetime] NOT NULL,
 CONSTRAINT [PK_Groups] PRIMARY KEY CLUSTERED 
(
	[GroupId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Users]    Script Date: 08/03/2012 16:31:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Users](
	[UserId] [int] NOT NULL,
	[Username] [varchar](32) NOT NULL,
	[Email] [varchar](64) NOT NULL,
	[PasswordHash] [varchar](max) NOT NULL,
	[PasswordSalt] [varchar](max) NOT NULL,
	[PersistenceToken] [varchar](max) NOT NULL,
	[PerishableToken] [varchar](max) NOT NULL,
	[LastRequestAt] [datetime] NULL,
	[LastLoginAt] [datetime] NULL,
	[CurrentLoginAt] [datetime] NULL,
	[LastLoginIp] [varchar](max) NULL,
	[CurrentLoginIp] [varchar](max) NULL,
	[LoginCount] [int] NOT NULL,
	[DeletedAt] [datetime] NULL,
	[CreatedAt] [datetime] NOT NULL,
	[UpdatedAt] [datetime] NOT NULL,
	[SuspendedAt] [datetime] NULL,
	[SingleAccessToken] [varchar](max) NULL,
 CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED 
(
	[UserId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Addresses]    Script Date: 08/03/2012 16:31:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Addresses](
	[Addressid] [int] NOT NULL,
	[Street1] [varchar](max) NULL,
	[Street2] [varchar](max) NULL,
	[Street3] [varchar](max) NULL,
	[City] [varchar](64) NULL,
	[State] [varchar](64) NULL,
	[PostCode] [varchar](16) NULL,
	[Country] [varchar](64) NULL,
	[Fulladdress] [varchar](max) NULL,
	[AddressTypeId] [int] NULL,
	[EntityLinkId] [int] NULL,
	[CreatedAt] [datetime] NOT NULL,
	[UpdatedAt] [datetime] NOT NULL,
	[DeletedAt] [datetime] NULL,
	[DoNotUse] [bit] NULL,
 CONSTRAINT [PK_Addresses] PRIMARY KEY CLUSTERED 
(
	[Addressid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
CREATE NONCLUSTERED INDEX [IX_AddressTypeId] ON [dbo].[Addresses] 
(
	[AddressTypeId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_EntityLinkId] ON [dbo].[Addresses] 
(
	[EntityLinkId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[ContactDetails]    Script Date: 08/03/2012 16:31:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[ContactDetails](
	[ContactDetailId] [int] NOT NULL,
	[Value] [varchar](max) NOT NULL,
	[EntityLinkId] [int] NULL,
	[ContactMethodTypeId] [int] NULL,
	[CreatedAt] [datetime] NOT NULL,
	[UpdatedAt] [datetime] NOT NULL,
	[DoNotUse] [bit] NULL,
	[IsPrimary] [bit] NULL,
 CONSTRAINT [PK_ContactDetails] PRIMARY KEY CLUSTERED 
(
	[ContactDetailId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
CREATE NONCLUSTERED INDEX [IX_ContactMethodTypeId] ON [dbo].[ContactDetails] 
(
	[ContactMethodTypeId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_EntityLinkId] ON [dbo].[ContactDetails] 
(
	[EntityLinkId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Comments]    Script Date: 08/03/2012 16:31:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Comments](
	[CommentId] [int] NOT NULL,
	[UserId] [int] NULL,
	[EntityLinkId] [int] NULL,
	[CommentTypeId] [int] NULL,
	[Private] [bit] NULL,
	[Title] [varchar](max) NULL,
	[Comment] [text] NULL,
	[CreatedAt] [datetime] NOT NULL,
	[UpdatedAt] [datetime] NOT NULL,
	[State] [varchar](16) NOT NULL,
 CONSTRAINT [PK_Comments] PRIMARY KEY CLUSTERED 
(
	[CommentId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
CREATE NONCLUSTERED INDEX [IX_CommentTypeId] ON [dbo].[Comments] 
(
	[CommentTypeId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_EntityLinkId] ON [dbo].[Comments] 
(
	[EntityLinkId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_UserId] ON [dbo].[Comments] 
(
	[UserId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[GroupsContacts]    Script Date: 08/03/2012 16:31:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[GroupsContacts](
	[GroupId] [int] NOT NULL,
	[ContactId] [int] NOT NULL,
	[DeletedAt] [datetime] NULL,
	[CreatedAt] [datetime] NOT NULL,
	[UpdatedAt] [datetime] NOT NULL
) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_ContactId] ON [dbo].[GroupsContacts] 
(
	[ContactId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_GroupId] ON [dbo].[GroupsContacts] 
(
	[GroupId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[EntityLinks]    Script Date: 08/03/2012 16:31:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[EntityLinks](
	[EnitityLinkId] [int] NOT NULL,
	[ContactId] [int] NULL,
	[GroupId] [int] NULL,
	[CreatedAt] [datetime] NOT NULL,
	[UpdatedAt] [datetime] NOT NULL,
	[DeletedAt] [datetime] NULL,
 CONSTRAINT [PK_EntityLinks] PRIMARY KEY CLUSTERED 
(
	[EnitityLinkId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_ContactId] ON [dbo].[EntityLinks] 
(
	[ContactId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_GroupId] ON [dbo].[EntityLinks] 
(
	[GroupId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[ContactInformationStreams]    Script Date: 08/03/2012 16:31:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ContactInformationStreams](
	[ContactId] [int] NOT NULL,
	[InformationStreamId] [int] NOT NULL,
	[IsEnabled] [bit] NULL,
	[CreatedAt] [datetime] NOT NULL,
	[UpdatedAt] [datetime] NOT NULL,
	[DeletedAt] [datetime] NULL
) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_ContactId] ON [dbo].[ContactInformationStreams] 
(
	[ContactId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_InformationStreamId] ON [dbo].[ContactInformationStreams] 
(
	[InformationStreamId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Avatars]    Script Date: 08/03/2012 16:31:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Avatars](
	[AvatarId] [int] NOT NULL,
	[EntityLinkId] [int] NULL,
	[ImageFileSize] [int] NULL,
	[ImageFileName] [varchar](max) NULL,
	[ImageContentType] [varchar](max) NULL,
	[AvatarTypeId] [int] NULL,
	[CreatedAt] [datetime] NOT NULL,
	[UpdatedAt] [datetime] NOT NULL,
 CONSTRAINT [PK_Avatars] PRIMARY KEY CLUSTERED 
(
	[AvatarId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
CREATE NONCLUSTERED INDEX [IX_AvatarTypeId] ON [dbo].[Avatars] 
(
	[AvatarTypeId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_EntityLinkId] ON [dbo].[Avatars] 
(
	[EntityLinkId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Contacts]    Script Date: 08/03/2012 16:31:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Contacts](
	[ContactId] [int] NOT NULL,
	[UserId] [int] NULL,
	[FirstName] [varchar](64) NOT NULL,
	[LastName] [varchar](64) NOT NULL,
	[MiddleNames] [varchar](150) NULL,
	[TitleId] [int] NULL,
	[BornOn] [datetime] NULL,
	[GenderId] [int] NULL,
	[DeletedAt] [datetime] NULL,
	[CreatedAt] [datetime] NOT NULL,
	[UpdatedAt] [datetime] NOT NULL,
 CONSTRAINT [PK_Contacts] PRIMARY KEY CLUSTERED 
(
	[ContactId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
CREATE NONCLUSTERED INDEX [IX_UserId] ON [dbo].[Contacts] 
(
	[UserId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
/****** Object:  Default [DF__address_t__creat__0C50D423]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[AddressTypes] ADD  DEFAULT (getdate()) FOR [CreatedAt]
GO
/****** Object:  Default [DF__address_t__updat__0D44F85C]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[AddressTypes] ADD  DEFAULT (getdate()) FOR [UpdatedAt]
GO
/****** Object:  Default [DF_contact_detail_types_created_at]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[ContactDetailTypes] ADD  CONSTRAINT [DF_contact_detail_types_created_at]  DEFAULT (getdate()) FOR [CreatedAt]
GO
/****** Object:  Default [DF_contact_detail_types_updated_at]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[ContactDetailTypes] ADD  CONSTRAINT [DF_contact_detail_types_updated_at]  DEFAULT (getdate()) FOR [UpdatedAt]
GO
/****** Object:  Default [DF_comment_types_created_at]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[CommentTypes] ADD  CONSTRAINT [DF_comment_types_created_at]  DEFAULT (getdate()) FOR [CreatedAt]
GO
/****** Object:  Default [DF_comment_types_updated_at]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[CommentTypes] ADD  CONSTRAINT [DF_comment_types_updated_at]  DEFAULT (getdate()) FOR [UpdatedAt]
GO
/****** Object:  Default [DF_information_streams_created_at]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[InformationStreams] ADD  CONSTRAINT [DF_information_streams_created_at]  DEFAULT (getdate()) FOR [CreatedAt]
GO
/****** Object:  Default [DF_information_streams_updated_at]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[InformationStreams] ADD  CONSTRAINT [DF_information_streams_updated_at]  DEFAULT (getdate()) FOR [UpdatedAt]
GO
/****** Object:  Default [DF_avatar_types_created_at]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[AvatarTypes] ADD  CONSTRAINT [DF_avatar_types_created_at]  DEFAULT (getdate()) FOR [CreatedAt]
GO
/****** Object:  Default [DF_avatar_types_updated_at]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[AvatarTypes] ADD  CONSTRAINT [DF_avatar_types_updated_at]  DEFAULT (getdate()) FOR [UpdatedAt]
GO
/****** Object:  Default [DF__groups__created___300424B4]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Groups] ADD  CONSTRAINT [DF__groups__created___300424B4]  DEFAULT (getdate()) FOR [CreatedAt]
GO
/****** Object:  Default [DF__groups__updated___30F848ED]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Groups] ADD  CONSTRAINT [DF__groups__updated___30F848ED]  DEFAULT (getdate()) FOR [UpdatedAt]
GO
/****** Object:  Default [DF__users__username__571DF1D5]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Users] ADD  CONSTRAINT [DF__users__username__571DF1D5]  DEFAULT ('') FOR [Username]
GO
/****** Object:  Default [DF__users__email__5812160E]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Users] ADD  CONSTRAINT [DF__users__email__5812160E]  DEFAULT ('') FOR [Email]
GO
/****** Object:  Default [DF__users__password___59063A47]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Users] ADD  CONSTRAINT [DF__users__password___59063A47]  DEFAULT ('') FOR [PasswordHash]
GO
/****** Object:  Default [DF__users__password___59FA5E80]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Users] ADD  CONSTRAINT [DF__users__password___59FA5E80]  DEFAULT ('') FOR [PasswordSalt]
GO
/****** Object:  Default [DF__users__persisten__5AEE82B9]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Users] ADD  CONSTRAINT [DF__users__persisten__5AEE82B9]  DEFAULT ('') FOR [PersistenceToken]
GO
/****** Object:  Default [DF__users__perishabl__5BE2A6F2]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Users] ADD  CONSTRAINT [DF__users__perishabl__5BE2A6F2]  DEFAULT ('') FOR [PerishableToken]
GO
/****** Object:  Default [DF__users__login_cou__5CD6CB2B]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Users] ADD  CONSTRAINT [DF__users__login_cou__5CD6CB2B]  DEFAULT ((0)) FOR [LoginCount]
GO
/****** Object:  Default [DF__users__created_a__5DCAEF64]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Users] ADD  CONSTRAINT [DF__users__created_a__5DCAEF64]  DEFAULT (getdate()) FOR [CreatedAt]
GO
/****** Object:  Default [DF__users__updated_a__5EBF139D]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Users] ADD  CONSTRAINT [DF__users__updated_a__5EBF139D]  DEFAULT (getdate()) FOR [UpdatedAt]
GO
/****** Object:  Default [DF__addresses__creat__0DAF0CB0]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Addresses] ADD  CONSTRAINT [DF__addresses__creat__0DAF0CB0]  DEFAULT (getdate()) FOR [CreatedAt]
GO
/****** Object:  Default [DF__addresses__updat__0EA330E9]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Addresses] ADD  CONSTRAINT [DF__addresses__updat__0EA330E9]  DEFAULT (getdate()) FOR [UpdatedAt]
GO
/****** Object:  Default [DF__comments__title__182C9B23]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Comments] ADD  CONSTRAINT [DF__comments__title__182C9B23]  DEFAULT ('') FOR [Title]
GO
/****** Object:  Default [DF__comments__create__1920BF5C]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Comments] ADD  CONSTRAINT [DF__comments__create__1920BF5C]  DEFAULT (getdate()) FOR [CreatedAt]
GO
/****** Object:  Default [DF__comments__update__1A14E395]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Comments] ADD  CONSTRAINT [DF__comments__update__1A14E395]  DEFAULT (getdate()) FOR [UpdatedAt]
GO
/****** Object:  Default [DF__comments__state__1B0907CE]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Comments] ADD  CONSTRAINT [DF__comments__state__1B0907CE]  DEFAULT ('Expanded') FOR [State]
GO
/****** Object:  Default [DF_groups_contacts_created_at]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[GroupsContacts] ADD  CONSTRAINT [DF_groups_contacts_created_at]  DEFAULT (getdate()) FOR [CreatedAt]
GO
/****** Object:  Default [DF_groups_contacts_updated_at]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[GroupsContacts] ADD  CONSTRAINT [DF_groups_contacts_updated_at]  DEFAULT (getdate()) FOR [UpdatedAt]
GO
/****** Object:  Default [DF_entity_links_created_at]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[EntityLinks] ADD  CONSTRAINT [DF_entity_links_created_at]  DEFAULT (getdate()) FOR [CreatedAt]
GO
/****** Object:  Default [DF_entity_links_updated_at]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[EntityLinks] ADD  CONSTRAINT [DF_entity_links_updated_at]  DEFAULT (getdate()) FOR [UpdatedAt]
GO
/****** Object:  Default [DF_entity_links_deleted_at]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[EntityLinks] ADD  CONSTRAINT [DF_entity_links_deleted_at]  DEFAULT (getdate()) FOR [DeletedAt]
GO
/****** Object:  Default [DF_contact_information_streams_is_enabled]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[ContactInformationStreams] ADD  CONSTRAINT [DF_contact_information_streams_is_enabled]  DEFAULT ((1)) FOR [IsEnabled]
GO
/****** Object:  Default [DF_contact_information_streams_created_at]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[ContactInformationStreams] ADD  CONSTRAINT [DF_contact_information_streams_created_at]  DEFAULT (getdate()) FOR [CreatedAt]
GO
/****** Object:  Default [DF_contact_information_streams_updated_at]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[ContactInformationStreams] ADD  CONSTRAINT [DF_contact_information_streams_updated_at]  DEFAULT (getdate()) FOR [UpdatedAt]
GO
/****** Object:  Default [DF__avatars__created__108B795B]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Avatars] ADD  CONSTRAINT [DF__avatars__created__108B795B]  DEFAULT (getdate()) FOR [CreatedAt]
GO
/****** Object:  Default [DF__avatars__updated__117F9D94]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Avatars] ADD  CONSTRAINT [DF__avatars__updated__117F9D94]  DEFAULT (getdate()) FOR [UpdatedAt]
GO
/****** Object:  Default [DF__contacts__first___1FCDBCEB]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Contacts] ADD  CONSTRAINT [DF__contacts__first___1FCDBCEB]  DEFAULT ('') FOR [FirstName]
GO
/****** Object:  Default [DF__contacts__last_n__20C1E124]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Contacts] ADD  CONSTRAINT [DF__contacts__last_n__20C1E124]  DEFAULT ('') FOR [LastName]
GO
/****** Object:  Default [DF__contacts__create__239E4DCF]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Contacts] ADD  CONSTRAINT [DF__contacts__create__239E4DCF]  DEFAULT (getdate()) FOR [CreatedAt]
GO
/****** Object:  Default [DF__contacts__update__24927208]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Contacts] ADD  CONSTRAINT [DF__contacts__update__24927208]  DEFAULT (getdate()) FOR [UpdatedAt]
GO
/****** Object:  ForeignKey [FK_Addresses_AddressTypes]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Addresses]  WITH CHECK ADD  CONSTRAINT [FK_Addresses_AddressTypes] FOREIGN KEY([AddressTypeId])
REFERENCES [dbo].[AddressTypes] ([AddressTypeId])
GO
ALTER TABLE [dbo].[Addresses] CHECK CONSTRAINT [FK_Addresses_AddressTypes]
GO
/****** Object:  ForeignKey [FK_Addresses_EntityLinks]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Addresses]  WITH CHECK ADD  CONSTRAINT [FK_Addresses_EntityLinks] FOREIGN KEY([EntityLinkId])
REFERENCES [dbo].[EntityLinks] ([EnitityLinkId])
GO
ALTER TABLE [dbo].[Addresses] CHECK CONSTRAINT [FK_Addresses_EntityLinks]
GO
/****** Object:  ForeignKey [FK_ContactDetails_ContactDetailTypes]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[ContactDetails]  WITH CHECK ADD  CONSTRAINT [FK_ContactDetails_ContactDetailTypes] FOREIGN KEY([ContactMethodTypeId])
REFERENCES [dbo].[ContactDetailTypes] ([ContactDetailTypeId])
GO
ALTER TABLE [dbo].[ContactDetails] CHECK CONSTRAINT [FK_ContactDetails_ContactDetailTypes]
GO
/****** Object:  ForeignKey [FK_ContactDetails_EntityLinks]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[ContactDetails]  WITH CHECK ADD  CONSTRAINT [FK_ContactDetails_EntityLinks] FOREIGN KEY([EntityLinkId])
REFERENCES [dbo].[EntityLinks] ([EnitityLinkId])
GO
ALTER TABLE [dbo].[ContactDetails] CHECK CONSTRAINT [FK_ContactDetails_EntityLinks]
GO
/****** Object:  ForeignKey [FK_Comments_CommentTypes]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Comments]  WITH CHECK ADD  CONSTRAINT [FK_Comments_CommentTypes] FOREIGN KEY([CommentTypeId])
REFERENCES [dbo].[CommentTypes] ([CommentTypeId])
GO
ALTER TABLE [dbo].[Comments] CHECK CONSTRAINT [FK_Comments_CommentTypes]
GO
/****** Object:  ForeignKey [FK_Comments_EntityLinks]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Comments]  WITH CHECK ADD  CONSTRAINT [FK_Comments_EntityLinks] FOREIGN KEY([EntityLinkId])
REFERENCES [dbo].[EntityLinks] ([EnitityLinkId])
GO
ALTER TABLE [dbo].[Comments] CHECK CONSTRAINT [FK_Comments_EntityLinks]
GO
/****** Object:  ForeignKey [FK_Comments_Users]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Comments]  WITH CHECK ADD  CONSTRAINT [FK_Comments_Users] FOREIGN KEY([UserId])
REFERENCES [dbo].[Users] ([UserId])
GO
ALTER TABLE [dbo].[Comments] CHECK CONSTRAINT [FK_Comments_Users]
GO
/****** Object:  ForeignKey [FK_GroupsContacts_Contacts]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[GroupsContacts]  WITH CHECK ADD  CONSTRAINT [FK_GroupsContacts_Contacts] FOREIGN KEY([ContactId])
REFERENCES [dbo].[Contacts] ([ContactId])
GO
ALTER TABLE [dbo].[GroupsContacts] CHECK CONSTRAINT [FK_GroupsContacts_Contacts]
GO
/****** Object:  ForeignKey [FK_GroupsContacts_Groups]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[GroupsContacts]  WITH CHECK ADD  CONSTRAINT [FK_GroupsContacts_Groups] FOREIGN KEY([GroupId])
REFERENCES [dbo].[Groups] ([GroupId])
GO
ALTER TABLE [dbo].[GroupsContacts] CHECK CONSTRAINT [FK_GroupsContacts_Groups]
GO
/****** Object:  ForeignKey [FK_EntityLinks_Contacts]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[EntityLinks]  WITH CHECK ADD  CONSTRAINT [FK_EntityLinks_Contacts] FOREIGN KEY([ContactId])
REFERENCES [dbo].[Contacts] ([ContactId])
GO
ALTER TABLE [dbo].[EntityLinks] CHECK CONSTRAINT [FK_EntityLinks_Contacts]
GO
/****** Object:  ForeignKey [FK_EntityLinks_Groups]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[EntityLinks]  WITH CHECK ADD  CONSTRAINT [FK_EntityLinks_Groups] FOREIGN KEY([GroupId])
REFERENCES [dbo].[Groups] ([GroupId])
GO
ALTER TABLE [dbo].[EntityLinks] CHECK CONSTRAINT [FK_EntityLinks_Groups]
GO
/****** Object:  ForeignKey [FK_ContactInformationStreams_Contacts]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[ContactInformationStreams]  WITH CHECK ADD  CONSTRAINT [FK_ContactInformationStreams_Contacts] FOREIGN KEY([ContactId])
REFERENCES [dbo].[Contacts] ([ContactId])
GO
ALTER TABLE [dbo].[ContactInformationStreams] CHECK CONSTRAINT [FK_ContactInformationStreams_Contacts]
GO
/****** Object:  ForeignKey [FK_ContactInformationStreams_InformationStreams]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[ContactInformationStreams]  WITH CHECK ADD  CONSTRAINT [FK_ContactInformationStreams_InformationStreams] FOREIGN KEY([InformationStreamId])
REFERENCES [dbo].[InformationStreams] ([InformationStreamId])
GO
ALTER TABLE [dbo].[ContactInformationStreams] CHECK CONSTRAINT [FK_ContactInformationStreams_InformationStreams]
GO
/****** Object:  ForeignKey [FK_Avatars_AvatarTypes]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Avatars]  WITH CHECK ADD  CONSTRAINT [FK_Avatars_AvatarTypes] FOREIGN KEY([AvatarTypeId])
REFERENCES [dbo].[AvatarTypes] ([AvatarTypeId])
GO
ALTER TABLE [dbo].[Avatars] CHECK CONSTRAINT [FK_Avatars_AvatarTypes]
GO
/****** Object:  ForeignKey [FK_Avatars_EntityLinks]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Avatars]  WITH CHECK ADD  CONSTRAINT [FK_Avatars_EntityLinks] FOREIGN KEY([EntityLinkId])
REFERENCES [dbo].[EntityLinks] ([EnitityLinkId])
GO
ALTER TABLE [dbo].[Avatars] CHECK CONSTRAINT [FK_Avatars_EntityLinks]
GO
/****** Object:  ForeignKey [FK_ContactsUsers]    Script Date: 08/03/2012 16:31:54 ******/
ALTER TABLE [dbo].[Contacts]  WITH CHECK ADD  CONSTRAINT [FK_ContactsUsers] FOREIGN KEY([UserId])
REFERENCES [dbo].[Users] ([UserId])
GO
ALTER TABLE [dbo].[Contacts] CHECK CONSTRAINT [FK_ContactsUsers]
GO
